#ifndef SALEDAO_H
#define SALEDAO_H

#include "database.h"
#include <QString>

class SaleDAO
{
public:
    explicit SaleDAO(Database *db);

    // 添加销售记录
    bool addSaleRecord(int productId, int quantity, double price,
                      int customerId, int operatorId, const QString &note = "");

    // 获取所有销售记录（用于统计页面）
    QVector<QMap<QString, QVariant>> getAllSaleRecords();
    
    // 根据条件查询销售记录
    QVector<QMap<QString, QVariant>> getSaleRecordsByCondition(
        const QString &startDate = "", const QString &endDate = "",
        int productId = -1, int customerId = -1);

    // 事务处理
    bool beginTransaction();
    bool commitTransaction();
    bool rollbackTransaction();

private:
    Database *m_db;
};

#endif // SALEDAO_H